import java.io.InputStream;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.net.URL;
import java.net.MalformedURLException;
import java.util.concurrent.Future;

import com.google.appengine.api.urlfetch.URLFetchService;
import com.google.appengine.api.urlfetch.URLFetchServiceFactory;
import com.google.appengine.api.urlfetch.HTTPRequest;
import com.google.appengine.api.urlfetch.HTTPResponse;

class UrlFetchLocalImpl extends UrlFetchServiceWrapper {
	String url;

	public UrlFetchLocalImpl(String url) {
		super(url);
		this.url = url;
	}

	public InputStream getInputStream() {
		try {
			return new URL(url).openStream();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

	public byte[] getBytes() {
		String ret = new String();
		byte[] b = new byte[1024*64];
		int num;

		InputStream is = getInputStream();
		try {
			while((num = is.read(b)) != -1)
				ret += new String(b, 0, num);
		} catch (IOException ie) {
			ie.printStackTrace();
		}

		return ret.getBytes();
	}
};
